<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            height: 500px;
            width: 500px;
            background-color: pink;
        }
    </style>
</head>
<body>
    <div class="box">

    </div>
    <script>
        // e.pageX获取鼠标到浏览器页面的宽度
        //this.offsetLeft 获取盒子到浏览器的宽度
        var box=document.querySelector('.box');
        box.addEventListener('click',function(e){
           var x = e.pageX - this.offsetLeft;
           var y = e.pageY - this.offsetTop;
           this.innerHTML = 'X的坐标是'+ x + 'Y的坐标是'+y;

        })
    </script>
</body>
</html>